<?php
	session_start();	
?>

<?php
	if( $_SESSION["admin"] != "" )
	{
?>
<script type="text/javascript" language="javascript">
function validateForm()
{
  var valid="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  var formObj;
  formObj = document.addcountry;
  if (formObj.country_code.value == "") {
    alert("You have not filled in admin code.");
    formObj.CouponCode.focus();
    return false;
  }
    if (formObj.country_name.value == "") {
    alert("You have not filled in admin name.");
    formObj.CouponTitle.focus();
    return false;
  }
  }
    
return true;
}
</script>
<a href="index.php?com=admin"><b>List admin</a></b> | <b><a href="index.php?com=admin&func=add">Add new admin</b></a>
<br />
<?php 
	include_once("process/admin.php");
	$admin = new admin();
    if( isset($_POST['btnAdd']) )
	{		
			$Username = stripcslashes($_POST["Username"]);
    		$Password=stripcslashes($_POST["Password"]);
    		$Level=stripcslashes($_POST["Level"]);
            $Email=stripcslashes($_POST["Email"]);
            $FirstName=stripcslashes($_POST["FirstName"]);
            $LastName=stripcslashes($_POST["LastName"]);
            $Phone=stripcslashes($_POST["Phone"]);
            $ActiveYN=stripcslashes($_POST["ActiveYN"]);
            $CreatedDate=date('Y-m-d H:i:s', time());
        //echo $code, $name, $order;
        if($Username != "" && $Password != "" && $Email != "" && $FirstName != "" && $LastName != "")
        {
    		$admin->AddAdmin($Username, $Password, $Level, $Email, $FirstName,
             $LastName, $Phone, $ActiveYN, $CreatedDate);	
    	//	echo '<meta http-equiv="Refresh" content="0;URL=index.php?com=admin" />';
    		//return;
        }
	}
?>

<form method="post" action="index.php?com=admin&func=add" id="contactform"  name="addcountry">
	<table width="70%" style="font-size:10pt;">
		<tr>
			<td align="center" colspan="2" height="50"><b style="font-size:12pt; color:Blue;">Add new admin</b></td>
		</tr>
		<tr style="font-weight:bold;">
			<td align="right">Username :&nbsp;&nbsp;</td>
			<td>
				<input class="validate[required]" type="text" name="Username" id="Username" /><font style="color: red;"> *</font>
			</td>
		</tr>
        <tr style="font-weight:bold;">
			<td align="right">Password :&nbsp;&nbsp;</td>
			<td>
				<input class="validate[required]" type="text" name="Password" id="Password" /><font style="color: red;"> *</font>
			</td>
		</tr>
        	<tr style="font-weight:bold;">
			<td align="right">Level :&nbsp;&nbsp;</td>
			<td>
				
                <input type="text" name="Level" id="Level" />
               
			</td>
		</tr>
        <tr style="font-weight:bold;">
			<td align="right">Email :&nbsp;&nbsp;</td>
			<td>
				<input type="text" name="Email" id="Email" class="validate[required]"/><font style="color: red;"> *</font>
			</td>
		</tr>
         <tr style="font-weight:bold;">
			<td align="right">FirstName :&nbsp;&nbsp;</td>
			<td>
				<input type="text" name="FirstName" id="FirstName" />
			</td>
		</tr>
        <tr style="font-weight:bold;">
			<td align="right">LastName :&nbsp;&nbsp;</td>
			<td>
				<input type="text" name="LastName" id="LastName" />
			</td>
		</tr>
        <tr style="font-weight:bold;">
			<td align="right">Phone :&nbsp;&nbsp;</td>
			<td>
				<input type="text" name="Phone" id="Phone" />
			</td>
		</tr>
        <tr style="font-weight:bold;">
			<td align="right">ActiveYN :&nbsp;&nbsp;</td>
			<td>
				<select size="1" name="ActiveYN">
        			<option value="No">No</option>
                    <option value="Yes">Yes</option>
			 </select>
			</td>
		</tr>
		<tr>
			<td></td>
			<td colspan="2" align="left" height="40">
				<input type="submit" name="btnAdd" id="btnAdd" value="Add"  />
				<input type="reset" value="Reset" />
			</td>
		</tr>
	</table>
</form>
<i>Please fill in these fields (<font style="color: red;">*</font>)</i>
<?php
     }
   else
	{
		echo "<meta http-equiv='refresh' content='0; url=login.php' />";
	}
?>